﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ProduceBasicData.Api.Application.Command.IncomingMaterialsManage;
using ProduceBasicData.Api.DTO.IncomingMaterialsDto;

using ProduceBasicData.ErrorCode;

namespace ProduceBasicData.Api.Controllers.IncomingMaterialsManage
{
    /// <summary>
    /// 检验方案
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class InspectionSchemeController : ControllerBase
    {
        private readonly IMediator _mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public InspectionSchemeController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 创建检验方案
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> CreateInspectionScheme(CreateInspectionSchemeCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 获取检验方案列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<InspectionSchemeDto>> GetInspectionSchemeList([FromQuery] GetInspectionSchemeCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 更新检验方案
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateInspectionScheme(UpdateInspectionSchemeCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 删除检验方案
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DeleteInspectionScheme(DeleteInspectionSchemeCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 检验方案批量删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DeleteRangeInspectionScheme(DeleteRangeInspectionSchemeCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
